package Demo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2022-04-25
 * Time: 下午 18:03
 */

class Animal {

}

class Student2 extends Animal {

}

class duck extends Student2{

}


class Sleep2<T> {
    private T name;

    public T getName() {
        return name;
    }

    public void setName(T name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Sleep2{" +
                "name=" + name +
                '}';
    }
}


public class TestDemo1 {
    public static void main(String[] args) {
        Sleep2<Animal> sleep1 = new Sleep2<>();
        Sleep2<Student2> sleep2 = new Sleep2<>();
        Sleep2<duck> sleep3 = new Sleep2<>();
        String namne="wenxiwen";
        fun1(sleep1);

    }

    public static void fun1(Sleep2<? super Student2> sleep2) {

        sleep2.setName(new Student2());
        sleep2.setName(new duck());

       /* Animal animal = sleep2.getName();
        System.out.println(animal);*/
    }
    /*public static void main2(String[] args) {
        Sleep2<Animal> sleep1= new Sleep2<>();
        Sleep2<Student2> sleep2 = new Sleep2<>();
        Sleep2<duck> sleep3 = new Sleep2<>();

        fun(sleep1);
        fun(sleep2);
    }*/

    /*public static void fun(Sleep2<? extends Animal> sleep2) {
        Animal animal = sleep2.getName();
        System.out.println(animal);
    }*/
   /* public static void main1(String[] args) {
        List<Animal> animal = new ArrayList<>();
        List<Student1> student1 = new ArrayList<>();*/
        /* animal = student1;*/

    }
}